﻿@{
    ViewBag.Title = "GetWorkShop";
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 引入 layui.css -->
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <script src="~/layui/layui.js"></script>
    <script src="~/libs/jquery/jquery.js"></script>
</head>
<body>
    <form class="layui-form" action="" onsubmit="return false">
        <div class="layui-form-item">
            <label class="layui-form-label">车间编码</label>
            <div class="layui-input-block">
                <input type="text" id="workShopCode" name="workShopCode" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">车间名称</label>
            <div class="layui-input-block">
                <input type="text" id="workShopName" name="workShopName" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">面积</label>
            <div class="layui-input-block">
                <input type="text" id="area" name="area" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">负责人</label>
            <div class="layui-input-block">
                <input type="text" id="charger" name="charger" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="radio" id="isEnable" name="isEnable" value="true" title="是">
                <input type="radio" id="isEnable" name="isEnable" value="false" title="否">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea" name="remark" id="remark"></textarea>
            </div>
        </div>
        <input type="hidden" id="id" name="id" />
    </form>
    <script>
        layui.use(['form', 'jquery', 'element'], function () {
            var form = layui.form,
                $ = layui.jquery;
                $ = layui.$;
            form.render();
            var id = window.location.search.substring(4);
            console.log(window.location.search)
            console.log(id)
            //获取车间信息           
            function getWorkShop(){

                $.ajax({
                    url: "/WorkShop/getWorkShopBy?id=" + id,
                    type:"get",
                    dataType:"json",
                    success: function (res) {
                        $("#id").val(id);
                        console.log($("#id").val());
                        $('#workShopCode').val(res.workShopCode);
                        $('#workShopName').val(res.workShopName);
                        $('#area').val(res.area);
                        $('#charger').val(res.charger);
                        $('input[name="isEnable"][value="' + res.isEnable + '"]').prop('checked', true);
                        $('#remark').val(res.remark);
                    }
                })
            }
            //获取车间信息
            getWorkShop();
           
        
    });
    </script>
</body>
</html>
